Skip to content

Fix examples + Copy example button#22

Merged
Sander-Toonen merged 2 commits into
masterfrom
fix/examples
Jan 23, 2026
Merged

Fix examples + Copy example button#22
Sander-Toonen merged 2 commits into
masterfrom
fix/examples

Conversation

@Sander-Toonen

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings January 23, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the language-service sample to support example-specific deep links and a “copy example link” button, and wires in a separate examples script. It also updates the sample server to serve the new script.

Changes:

  • serve-sample.cjs: Adds routing to serve /examples.js alongside existing sample assets.
  • index.html: Includes a new examples.js script before app.js.
  • app.js: Moves example data out of this file (now assumed to live in examples.js), adds a copyExampleLink helper, and augments the examples sidebar with “copy link” buttons and URL-based example loading.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
samples/language-service-sample/serve-sample.cjs Adds routing logic so /examples.js is served from the sample directory.
samples/language-service-sample/index.html Loads the new examples.js script before app.js to provide example data and deep-link support.
samples/language-service-sample/app.js Removes inline example definitions, consumes exampleCases from the external script, and implements the copy-link UX and URL-driven example loading.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (urlPath === '/' || urlPath === '/index.html') {
urlPath = 'samples/language-service-sample/index.html';
} else if (urlPath === '/styles.css' || urlPath === '/app.js') {
} else if (urlPath === '/styles.css' || urlPath === '/app.js' || urlPath === '/examples.js') {

Copilot AI Jan 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server is configured to serve /examples.js from samples/language-service-sample/examples.js, but that file does not exist, so requests to this path will always return 404. Once examples.js is added (or if you decide to inline examples instead), this route should be updated accordingly.

Suggested change
} else if (urlPath === '/styles.css' || urlPath === '/app.js' || urlPath === '/examples.js') {
} else if (urlPath === '/styles.css' || urlPath === '/app.js') {

Copilot uses AI. Check for mistakes.
const examplesList = document.getElementById('examplesList');
if (!examplesList) return;

examplesList.innerHTML = exampleCases.map(example => `

Copilot AI Jan 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exampleCases is referenced here but no longer defined in this file and there is no other definition in the repo, so this will throw a ReferenceError at runtime unless a global exampleCases is provided (e.g., by the new examples.js). Either reintroduce the data here or ensure examples.js exists, defines exampleCases on the global scope, and is loaded before this script.

Suggested change
examplesList.innerHTML = exampleCases.map(example => `
const examples = (window.exampleCases || []);
examplesList.innerHTML = examples.map(example => `

Copilot uses AI. Check for mistakes.
<span>Saved to localStorage</span>
</div>

<script src="examples.js"></script>

Copilot AI Jan 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script tag loads examples.js, but there is no corresponding samples/language-service-sample/examples.js file in the repository, so the browser will 404 this request and any globals (like exampleCases) it is supposed to define will be missing. Please add the file to the sample folder or remove this tag and keep the examples inline.

Suggested change
<script src="examples.js"></script>

Copilot uses AI. Check for mistakes.
@Sander-Toonen Sander-Toonen merged commit 0a7ef50 into master Jan 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants